alter function f_getasciino
(
  @string nvarchar(200)
)
RETURNS int
as
begin
-- Create the variables for the current character string position 
-- and for the character string.
DECLARE @position int, @r int, @asc int
-- Initialize the variables.
  SELECT @position = 1, @r=0
  WHILE @position <= DATALENGTH(@string)
  BEGIN
    SELECT @asc=ASCII(SUBSTRING(@string, @position, 1))
    if @asc is not null
      SELECT @r=@r+@asc
    SET @position = @position + 1
  END
  RETURN @r
end